package com.feiwo.nonego.rpc.reflect.cglib;

import com.feiwo.nonego.rpc.reflect.api.ReflectInvoker;
import com.feiwo.nonego.rpc.spi.annotation.SPIClass;
import net.sf.cglib.reflect.FastClass;

/**
 *
 *
 * @author feiwo 2025-08-17
 */
@SPIClass
public class CglibReflectInvoker implements ReflectInvoker {

    @Override
    public Object invoke(Object serviceBean, Class<?> serviceClass, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws Throwable {
        var serviceFastClass = FastClass.create(serviceClass);
        var fastMethod = serviceFastClass.getMethod(methodName, parameterTypes);
        return fastMethod.invoke(serviceBean, parameters);
    }
}
